package com.ruoyi.business.controller;

import com.ruoyi.business.domain.BusinessManualConfig;
import com.ruoyi.business.service.IBusinessManualConfigService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 手工交易参数配置Controller
 * 
 * @author ruoyi
 * @date 2024-05-14
 */
@RestController
@RequestMapping("/manual/config")
public class BusinessManualConfigController extends BaseController
{
    @Autowired
    private IBusinessManualConfigService businessManualConfigService;

    /**
     * 查询手工交易参数配置列表
     */
    @PreAuthorize("@ss.hasPermi('system:config:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusinessManualConfig businessManualConfig)
    {
        startPage();
        List<BusinessManualConfig> list = businessManualConfigService.selectBusinessManualConfigList(businessManualConfig);
        return getDataTable(list);
    }

    /**
     * 导出手工交易参数配置列表
     */
    @PreAuthorize("@ss.hasPermi('system:config:export')")
    @Log(title = "手工交易参数配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusinessManualConfig businessManualConfig)
    {
        List<BusinessManualConfig> list = businessManualConfigService.selectBusinessManualConfigList(businessManualConfig);
        ExcelUtil<BusinessManualConfig> util = new ExcelUtil<BusinessManualConfig>(BusinessManualConfig.class);
        util.exportExcel(response, list, "手工交易参数配置数据");
    }

    /**
     * 获取手工交易参数配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:config:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(businessManualConfigService.selectBusinessManualConfigById(id));
    }

    /**
     * 新增手工交易参数配置
     */
    @PreAuthorize("@ss.hasPermi('system:config:add')")
    @Log(title = "手工交易参数配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusinessManualConfig businessManualConfig)
    {
        return toAjax(businessManualConfigService.insertBusinessManualConfig(businessManualConfig));
    }

    /**
     * 修改手工交易参数配置
     */
    @PreAuthorize("@ss.hasPermi('system:config:edit')")
    @Log(title = "手工交易参数配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusinessManualConfig businessManualConfig)
    {
        return toAjax(businessManualConfigService.updateBusinessManualConfig(businessManualConfig));
    }

    /**
     * 删除手工交易参数配置
     */
    @PreAuthorize("@ss.hasPermi('system:config:remove')")
    @Log(title = "手工交易参数配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(businessManualConfigService.deleteBusinessManualConfigByIds(ids));
    }
}
